<?php

require_once ('Zend/Sql/Adapter/Standard/Expression/Identifier/Table.php');

class Zend_Sql_Adapter_Standard_Expression_Identifier_Column
	extends Zend_Sql_Adapter_Standard_Expression_Identifier_Table
{
	/**
	 * @var string
	 */
	protected $column;
	
	/**
	 * 
	 * @param string $name
	 * @param string $table
	 * @param string $schema
	 */
	public function __construct($name=null, $table=null, $schema=null) {
		if (isset($name)) {
			$this->setColumn($name);
		}
		parent::__construct($table, $schema);
	}
	
	/**
	 * @return the $column
	 */
	public function getColumn() {
		return $this->column;
	}

	/**
	 * @param string $column
	 */
	public function setColumn($column) {
		$this->column = $column;
	}
	
	/**
	 * @return the $column
	 */
	public function toString() {
		$table = parent::toString();
		if ($table) {
			$table = $table . '.';
			if (!$this->column) {
				require_once ('Zend/Sql/Exception.php');
				throw new Zend_Sql_Exception('Unexcepted table name or empty column name');
			}
		}
		
		$column = '';
		if ($this->column) {
			$column = $table . '`' . $this->column . '`';
		}
		
		return $column;
	}
	
	/**
	 * override
	 * @return the $column
	 */
	public function getName() {
		return $this->getColumn();
	}
	/**
	 * override
	 * @return the $column
	 */
	public function setName($name) {
		return $this->setColumn($name);
	}
}
